package com.whnk.web.controller.rtms;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.whnk.common.annotation.Log;
import com.whnk.common.enums.BusinessType;
import com.whnk.rtms.domain.PrjVrsnDtRel;
import com.whnk.rtms.service.IPrjVrsnDtRelService;
import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.common.base.AjaxResult;

/**
 * 项目和版本日期关系 信息操作处理
 * 
 * @author whwhnk
 * @date 2019-04-30
 */
@Controller
@RequestMapping("/rtms/prjVrsnDtRel")
public class PrjVrsnDtRelController extends BaseController
{
    private String prefix = "rtms/prjVrsnDtRel";
	
	@Autowired
	private IPrjVrsnDtRelService prjVrsnDtRelService;
	
	@RequiresPermissions("rtms:prjVrsnDtRel:view")
	@GetMapping()
	public String prjVrsnDtRel()
	{
	    return prefix + "/prjVrsnDtRel";
	}
	
	/**
	 * 查询项目和版本日期关系列表
	 */
	@RequiresPermissions("rtms:prjVrsnDtRel:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PrjVrsnDtRel prjVrsnDtRel)
	{
		startPage();
        List<PrjVrsnDtRel> list = prjVrsnDtRelService.selectPrjVrsnDtRelList(prjVrsnDtRel);
		return getDataTable(list);
	}
	
	/**
	 * 新增项目和版本日期关系
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存项目和版本日期关系
	 */
	@RequiresPermissions("rtms:prjVrsnDtRel:add")
	@Log(title = "项目和版本日期关系", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PrjVrsnDtRel prjVrsnDtRel)
	{		
		return toAjax(prjVrsnDtRelService.insertPrjVrsnDtRel(prjVrsnDtRel));
	}

	/**
	 * 修改项目和版本日期关系
	 */
	@GetMapping("/edit/{prjId}")
	public String edit(@PathVariable("prjId") String prjId, ModelMap mmap)
	{
		PrjVrsnDtRel prjVrsnDtRel = prjVrsnDtRelService.selectPrjVrsnDtRelById(prjId);
		mmap.put("prjVrsnDtRel", prjVrsnDtRel);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存项目和版本日期关系
	 */
	@RequiresPermissions("rtms:prjVrsnDtRel:edit")
	@Log(title = "项目和版本日期关系", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PrjVrsnDtRel prjVrsnDtRel)
	{		
		return toAjax(prjVrsnDtRelService.updatePrjVrsnDtRel(prjVrsnDtRel));
	}
	
	/**
	 * 删除项目和版本日期关系
	 */
	@RequiresPermissions("rtms:prjVrsnDtRel:remove")
	@Log(title = "项目和版本日期关系", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(prjVrsnDtRelService.deletePrjVrsnDtRelByIds(ids));
	}
	
}
